package cn.edu.scau.cmi.dengshixin.adapter.objectAdapter;

import java.util.ArrayList;
import java.util.HashMap;

import cn.edu.scau.cmi.dengshixin.adapter.SortUtil;
import cn.edu.scau.cmi.dengshixin.adapter.Student;
import cn.edu.scau.cmi.dengshixin.adapter.Target;

public class ObjectAdapter implements Target {

	@Override
	public void sortStudent(ArrayList<Student> studentList) {
		HashMap<Integer, Student> m = new HashMap<Integer, Student>();
		ArrayList<Integer> intList = new ArrayList<Integer>();
		for(int i=0; i<studentList.size(); i++) {
			intList.add(studentList.get(i).getId());
			m.put(studentList.get(i).getId(), studentList.get(i));
		}	
		SortUtil.sortInt(intList);
		studentList.clear();
		for(Integer i : intList) {
			studentList.add(m.get(i));
		}
	}


}
